package day03;

import java.util.Scanner;

//运算符的演示
public class OperDemo {
    public static void main(String[] args) {

        /*
        //6.三目运算
        // 表达式: boolean?数1:数2

        int x,y,z;
        Scanner sc = new Scanner(System.in);
        System.out.println("请输入三个值:");
        x = sc.nextInt();
        y = sc.nextInt();
        z = sc.nextInt();
        int max = x>y?(x>z?x:z):(y>z?y:z);
        System.out.println(max);

         */










        /*
        5.字符串连接运算符
            1. + : 连接符
                1.1 若两边为数字,则做加法运算
                1.2 若两边出现字符串,则做字符串连接
         */

        /*
        String name="123",pw="123";
        if (name=="123" && pw=="123"){
            System.out.println("欢迎用户"+name);
        }else{
            System.out.println("账号或密码错误");
        }

        System.out.println(10+20+""+30);//3030-------String
        System.out.println(""+10+20+30);//102030------String
        System.out.println(10+20+30+"");//60-------String
        System.out.println("今天情人节,希望你未来的老婆少挨几炮");

         */










        /*
        //  +=,-=,*=,/=
        short s = 5;
        //s = s+10; //编译错误,需要强转  改为s=(short)(s+10);
        s += 10;//相当于s=(short)(s+10);


        int a = 5;
        a += 10;//相当于a = (int)(a+10);
        System.out.println(a);//15
        a -= 5;//相当于a = (int)(a-5);
        System.out.println(10);//10
        a *= 2;//相当于a = (int)(a*2);
        System.out.println(a);//20
        a /= 5;//相当于a = (int)(a/5);
        System.out.println(a);//4

         */













        /*
        逻辑运算符
            1.&&:短路与(并且),两个条件都为真,见false则false
            2.||:短路或(或者),一个条件为真就真,见true则ture
            3. !:逻辑非:取反
         */

        /*
        //年龄在18到50之间
        int age = 32;
        System.out.println(age>=18 && age<=50);//true
         */


        /*
        int a = 5,b = 10,c = 5;
        System.out.println(b>=a || b<c);
        System.out.println(b<=c || b>a);
        System.out.println(b!=c || b>a);
        System.out.println(a==b || b<a);

        int score = 90;
        System.out.println(score<0 || score>100);//不合法验证

        boolean b2 = !(a<b);
        System.out.println(b2);
         */






        /*
        int a = 5,b = 5;
        int c = a++;//先赋值给表达式,值5赋值给c,再自增1.所以c的值为5a的值为6
        int d = ++b;//先自增1,再参与运算,所以b的值为6,再赋值给d,d 的值为6
        System.out.println(a);//6
        System.out.println(b);//6
        System.out.println(c);//5
        System.out.println(d);//6

        System.out.println(a++);//先参与运算所以表达式的值为6,再自增1.为7
        System.out.println(++a);//前面a的值为7,先自增再参与表达式,所以表达式值为8
        */



        /*
        int a=5,b=10,c=5;
        boolean a1=a>b;
        System.out.println(a1);//false
        System.out.println(a++>5);//false ------a的值自增1,为6,a++的值为5
        System.out.println(a++>5);//true-----a的值自增1,为7,a++的值为6
        System.out.println(a);//7,因为上边a的值变化为7
        */












    }
}
